<!DOCTYPE html>
<html>
<head>
    <title>添加药品--中软高科-2015</title>
    <meta charset="UTF-8">
    <link rel="stylesheet" type="text/css" href="../Css/bootstrap.css" />
    <link rel="stylesheet" type="text/css" href="../Css/bootstrap-responsive.css" />
    <link rel="stylesheet" type="text/css" href="../Css/style.css" />
    <script type="text/javascript" src="../Js/jquery.js"></script>
    <script type="text/javascript" src="../Js/jquery.sorted.js"></script>
    <script type="text/javascript" src="../Js/bootstrap.js"></script>
    <script type="text/javascript" src="../Js/ckform.js"></script>
    <script type="text/javascript" src="../Js/common.js"></script>
    <script type="text/javascript" src="../Js/ckeditor/ckeditor.js"></script>
 

    <style type="text/css">
        body {
            padding-bottom: 40px;
        }
        .sidebar-nav {
            padding: 9px 0;
        }

        @media (max-width: 980px) {
            /* Enable use of floated navbar text */
            .navbar-text.pull-right {
                float: none;
                padding-left: 5px;
                padding-right: 5px;
            }
        }
    </style>
</head>
<body>
<form id="myForm" class="definewidth m20">
<table class="table table-bordered table-hover definewidth m10">
    <tr>
        <td width="10%" class="tableleft" >药品编号</td>
        <td id="id" name="id">J1121</td>
    </tr> 
	
    <tr>
        <td width="10%" class="tableleft">药品名称</td>
        <td id="drugName" name="drugName">感冒药</td>
    </tr>    
	<tr>
        <td width="10%" class="tableleft">余量</td>
        <td id="resetNumber" name="resetNumber">300</td>
    </tr>    
	
    <tr>
        <td width="10%" class="tableleft">数量</td>
        <td>
			<input id="increase" name="increase" type="text" value=""/>
		</td>
    </tr>
	

    <tr>
        <td colspan="2">
			<center>
				<button type="button" class="btn btn-primary" onclick="addMedicine()">增加库存</button> &nbsp;&nbsp;
                <button type="button" class="btn btn-success" onclick="black()">返回列表</button>
			</center>
		</td>
    </tr>
</table>
</form>
<script type="text/javascript">
    $(function (){
        show();
    })
    //显示
    function show() {
        //获取url
        (function($){
            $.getUrlParam
                = function(name)
            {
                var reg
                    = new RegExp("(^|&)"+
                    name +"=([^&]*)(&|$)");
                var r
                    = window.location.search.substr(1).match(reg);
                if (r!=null) return unescape(r[2]); return null;
            }
        })(jQuery);
        var id = $.getUrlParam('id');
        $.ajax({
            url:"/drug/getDrupById?id="+id,
            type:"GET",
            success:function(drug){
                $("#id").html(drug.id);
                $("#drugName").html(drug.drugName);
                $("#resetNumber").html(drug.resetNumber);
            }
        })
    }

    function black() {
        window.location.href="/Medicine/index.html";
    }
    
    function addMedicine(){
        var id = $("#id").html();
        var increase = $("#increase").val();
        $.ajax({
            url:"/drug/addResetNumber",
            type:"POST",
            data:{
                id:id,
                increase:increase
            },
            dataType:"json",
            success:function (ov){
                alert(ov.msg);
                if (ov.code==200){
                    black();
                }
            }
        })
    }
</script>
</body>
</html>